/*
 * simple_ai_1.cpp
 *
 *  Created on: 03-Jun-2009
 *      Author: christian
 */

#include "simple_ai_1.h"

namespace cta {

namespace ai {

simple_ai_1::simple_ai_1(object* obj_) {
	obj_ai = obj_;
	command = "";

}

bool simple_ai_1::follow(cta::object* obj_)
{
	obj_target = obj_;
	command = "FOLLOW";
	return true;
}

bool simple_ai_1::Run()
{
	if(command == "FOLLOW")
	{
		// Move Left / Right
		if(obj_ai->getPosition3d()[0] < obj_target->getPosition3d()[0])
			obj_ai->Command("MoveRight");
		else if(obj_ai->getPosition3d()[0] > obj_target->getPosition3d()[0])
			obj_ai->Command("MoveLeft");
		// Move Up / Down
		if(obj_ai->getPosition3d()[1] < obj_target->getPosition3d()[1])
			obj_ai->Command("MoveUp");
		else if(obj_ai->getPosition3d()[1] > obj_target->getPosition3d()[1])
			obj_ai->Command("MoveDown");
	}
	return true;
}

simple_ai_1::~simple_ai_1() {
	// TODO Auto-generated destructor stub
}

}

}
